// pages/Default/Default.js
Page({
  data: {
    userInfo: {},
    scrollHeight: 0,
    imgList: []
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    var that = this
    wx.getSystemInfo({
      success: function (res) {
        that.setData({
          scrollHeight: res.windowHeight
        })
        that.Get_All_Public_Album()
      }
    })
  },
  //获取全部公共相册
  Get_All_Public_Album(pnow = 1, pcount = 0, type = 1) {
    var t = this
    if (t.data.pnow) {
      if (t.data.pcount >= t.data.pnow) {
        var cpnow = t.data.pnow;
      } else {
        return;
      }
    } else {
      var cpnow = 1;
    }
    if (t.data.search) {
      var search = t.data.search.trim();
    } else {
      var search = '';
    }
    wx.request({
      url: 'https://photo.tobeyoung.net/Album.aspx',
      data: {
        GetTypes: 'Get_All_Public_Album',
        pnow: cpnow,
        pcount: pcount,
        search: search,
        type: type
      },
      success: function (res) {
        var iList = t.data.imgList
        for (var i = 0; i < res.data.DataList.length; i++) {
          if (res.data.DataList[i].Album_Pic_Cover != '0') {
            iList.push('https://photo.tobeyoung.net' + res.data.DataList[i].Album_Pic_Cover);
          } else {
            iList.push('https://photo.tobeyoung.net/Sites/Site34/Album/201706171410456363330544530672240.jpg');
          }
        }
        t.setData({
          pnow: parseInt(res.data.Pnow) + 1,
          pcount: parseInt(res.data.PageCount),
          imgList: iList
        })
      }
    })
  }

})